/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package backingBean;

import entites.Favorites;
import entites.Members;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import manager.FavoritesManager;

/**
 *
 * @author ambaye
 */
@ManagedBean(name="favoris")
@RequestScoped
public class Favoriteslistes implements Serializable{

@ManagedProperty(value = "#{login.members}")
        private Members unmembre;  

    public Members getUnmembre() {
        return unmembre;
    }

    public void setUnmembre(Members unmembre) {
        this.unmembre = unmembre;
    }

List<Favorites> malistedefavoris;
        


    public List<Favorites> getMalistedefavoris() {
        return malistedefavoris;
    }

    public void setMalistedefavoris(List<Favorites> malistedefavoris) {
        this.malistedefavoris = malistedefavoris;
    }

 
   @PostConstruct
    public void InitData(){   
       System.out.println("test1");
malistedefavoris=FavoritesManager.Afficherlesfavoris();
   }
   

   
    public void insertFavorie(int idUserAdd){       
        //id user from session
//        int idUserConnected = Session.get;
        
        HashMap IdUerAdd_IdUserConnected = new HashMap();
//            IdUerAdd_IdUserConnected.put("idUserConnected", idUserConnected);
            IdUerAdd_IdUserConnected.put("idUserAdd", idUserAdd);
        FavoritesManager.favoritesInsert(IdUerAdd_IdUserConnected);
    }
    public void deleteFavorie(int idUserAdd){       
       
        //id user from session
        int idUserConnected = 1;
        
        HashMap IdUerDelete_IdUserConnected = new HashMap();
            IdUerDelete_IdUserConnected.put("idUserConnected", idUserConnected);
            IdUerDelete_IdUserConnected.put("idUserAdd", idUserAdd);
        FavoritesManager.favoritesDelete(IdUerDelete_IdUserConnected);
    }
    public Favoriteslistes() {
    }
     
}
